package com.rightrule.rule.constans;

import java.util.Arrays;
import java.util.Optional;

public enum OutputFieldValueTypeEnum {

    ENUM("ENUM", "枚举类型"),
    NUM("NUM", "数值类型"),
    SELF_DEFINE("SELF_DEFINE", "自定义类型");


    private String code;
    private String desc;

    OutputFieldValueTypeEnum(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public String getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    public static Optional<OutputFieldValueTypeEnum> of(Integer code) {
        if (null == code) {
            return Optional.empty();
        }
        return Arrays.stream(values()).filter(typeEnum -> code.equals(typeEnum.getCode())).findFirst();
    }

}
